/*
-----------------------------------------------------------------------------
This source file is part of DIVA
The project of Engineering Lab, dept. of CSIE, NTNU.

Copyright (c) 2000-2006 The Software Engineering Lab, dept. of CSIE, NTNU.
-----------------------------------------------------------------------------
Filename:    ball_bool_ptvm.h
Description: 


-----------------------------------------------------------------------------
*/
/*------------------------------------------------------------*/
#ifndef _ubrvm_orbit_H_
#define	_ubrvm_orbit_H_
/*------------------------------------------------------------*/

#include "DIVA_VM.h"
#include "MovableText.h"
#include "ReferenceVM.h"
#include "xParameterPack.h"
#include "dummyVM.h"
#include "Line3D.h"
#include <string>

//using namespace Ogre;

class ubrvm_orbit: public ReferenceVM {
private:
	/// the entity and scenenode. 
	//Ogre::Entity* _ent;
	//Ogre::SceneNode* snode;

	Ogre::MovableText* _msg ;
	//SceneNode*   _text_scene_node ; // the scene node of the label
	//SceneNode*   _line_node ;
	dummyVM*     _proxyVM ;
	DIVA_VM*	 _shapeVM ;
	int*		 _velocity;
	int*         _radius;
	int			 _velocity_val;
	int          _radius_val;

	Ogre::SceneNode*   _head_node;
	Ogre::Entity*      _head_entity;
	
	Ogre::ParticleSystem* _parExp;
	Ogre::Vector3 oldPos;

	bool _clicked;
	bool _created;
	/// the mesh this vm used.
	//std::string meshName;
	Ogre::SceneNode* _line_node;
	Line3D *_myLine ;
	time_t t;
	void createOrbitNodeEntity();

public:
	/// constructor & destructor
	ubrvm_orbit(xParameterPack xpp);
	~ubrvm_orbit();

	void load_3Dresources();
	void reg_event_entity();
	void init_private_attrs_started() ;
	void init_color_and_transparency();
	void update_color_and_transparency();
	virtual void set_default_values();

	/// basic method that each vm has
	void VMPicked(Ogre::Real x,Ogre::Real y,Ogre::Real z);
	void VMSelected(Ogre::Real x,Ogre::Real y,Ogre::Real z){}
	//void VMDragged(Ogre::Real x,Ogre::Real y,Ogre::Real z);
	void VMAnimation(const Ogre::FrameEvent &);

	/// value update that  exchange the target vm this vm pointed to
	void VMValueUpdated();
    void VMSetVisible(bool vis) ;

	bool isSubComponent(DIVA_VM *vm);
	// the overridden method of OgreVM
	void scaleBodyToAbsSize(Ogre::Vector3 v);
	void setBodyScale(Ogre::Vector3);
	Ogre::Vector3 getOriginalBodySize();
	Ogre::Vector3 getActualSize();
	bool isBodyScaleWrtSceneNode();
	Ogre::Vector3 getBodyScale();	

	// 暫時的function - 將integer轉成string
	std::string intToString(int its){
		std::stringstream ss;
		std::string str;

		ss << its;
		str = ss.str();
		ss.str("");

		return str;
	}

};
/*------------------------------------------------------------*/
#endif	//#ifndef _Tree_Node_rtvm_H_
/*------------------------------------------------------------*/
